package oj0329.oj0329_05;

import java.util.Scanner;
import java.util.Stack;

public class Main {
    private static boolean Mat(String str){
//        创建栈
        Stack<Character> stack = new Stack<>();
//        遍历字符串
        for (int i = 0; i < str.length(); i++){
            char ch = str.charAt(i);
//            满足条件，入栈
            if (ch == '[' || ch == '(' || ch == '{'){
                stack.push(ch);
            }else { //右括号
//                非空才继续出栈
                if (!stack.isEmpty()){
                    char top = stack.peek();
                    if ((ch == ')' && top == '(') || (ch == '}' && top == '{') || (ch == ']' && top == '[')){
                        stack.pop();
                    }else {
                        return false;
                    }
                }else {
                    return false;
                }
            }

        }
        return stack.isEmpty();
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        boolean b = Mat(s);
        System.out.println(b ? "True" : "False");
    }
}
